import java.util.Vector;


public class OwnEvaluator implements Evaluation{

	@Override
	public int evaluateBoard(Board board) {
		Vector<Move> movOwn = new Vector<Move>();
    	Vector<Move> movOther = new Vector<Move>();
    	board.FindPossibleMoves(movOwn, Board.OWN);
    	board.FindPossibleMoves(movOther, Board.OTHER);
    	if (board.OwnCount()+board.OtherCount()<8)
    	{
    		return movOwn.size()-movOther.size();
    	}
    	else if ( (board.OwnCount()+board.OtherCount()) < Board.cSize*Board.cSize-4)
    	{
    		return edges(board, Board.OWN)*1000 - 2000* edges(board, Board.OTHER)+board.OwnCount()+movOwn.size()*10;
    	}
    	return board.OwnCount();	
    }
	
	private int edges(Board board, byte turn)
	{
		int count = 0;
		   if (board.At(0, 0)==turn)
			   count++;
		   if (board.At(0, 7)==turn)
			   count++;
		   if (board.At(7, 0)==turn)
			   count++;
		   if (board.At(7, 7)==turn)
			   count++;
		   
		   return count;
	}

	
}
